import store from '../store';
import { computed } from 'vue';
import { userShare } from '@/api/api';

export default {
  install(app) {
    app.mixin({
      data() {
        return {
          ASSETSURL: 'https://cdn1.vrupup.com/s/1407/20250414-xishi/image/',
          isOverShare: false,
        };
      },
      async onShareAppMessage() {
        let res = await userShare({ url: '' });
        console.log('测试分享', res);
        //分享配置
        return {
          path: 'pages/diy/diy?share_id=' + res.data,
		  imageUrl: this.ASSETSURL+'share.png',
          title: '禧栻文化：饰饰称心，事事如意',
        };
      },
      methods: {
        swiperClick(item) {
          console.log('轮播点击', item);
          item.jumpType = 2;
          if (item.is_jump == 0) return;
          switch (item.jumpType) {
            case 2:
              if (!item.jump_url.startsWith('/')) {
                item.jump_url = '/' + item.jump_url;
              }
              console.log(item.jump_url);
              uni.navigateTo({
                url: item.jump_url,
                fail: (err) => {
                  uni.switchTab({
                    url: item.jump_url,
                  });
                },
              });
              break;
            case 3:
              uni.navigateToMiniProgram({
                appId: item.appId,
                path: item.jump_url,
                success: (res) => {
                  // 打开成功
                  console.log('打开成功', res);
                },
                fail: (err) => {
                  console.log(err);
                },
              });
              break;
            case 5:
              uni.openChannelsActivity({
                finderUserName: item.spId,
                feedId: item.feedId,
                success(res) {
                  console.log(res);
                },
              });
              break;
            case 4:
              uni.navigateTo({
                url:
                  '/pages/web-page/web-page?url=' +
                  encodeURIComponent(JSON.stringify(item.jump_url)),
              });
              break;
          }
        },
      },
    });
  },
};
